package com.naiterui.ehp.bs.patient.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.naiterui.ehp.bp.domain.ConsultBill;
import com.naiterui.ehp.bs.patient.dao.IConsultBillDao;
import com.naiterui.ehp.bs.patient.repository.IApConsultBillRepository;

/**
 * 问诊账单持久化接口实现
 *
 * @author Amber
 * @since 1.0.0
 */
@Component
public class ApConsultBillDaoImpl implements IConsultBillDao {

    private IApConsultBillRepository consultBillRepository;

    @Override
    public int getUpPayBill(Long patientId) {
        List<ConsultBill> bills = this.consultBillRepository.getUnPayBills(patientId);
        return bills == null ? 0 : bills.size();
    }

    @Override
    public Map<Long, ConsultBill> getBillsByIds(List<Long> billIds) {
        Map<Long, ConsultBill> billMap = new HashMap<>();
        List<ConsultBill> bills = this.consultBillRepository.findByIdIn(billIds);
        for (ConsultBill bill : bills) {
            billMap.put(bill.getId(), bill);
        }
        return billMap;
    }
}
